package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_ElectronicTicket 电子券
 *
 */
public class TestData_TB_ElectronicTicket
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_ElectronicTicket saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ElectronicTicketOrder electronicTicketOrder
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_ElectronicTicket");
		return (TB_ElectronicTicket)repository.save(newMust(
				electronicTicketOrder
			));
	}
	
	public static TB_ElectronicTicket newMust(
		bairui.international.model.domain.jpa.TB_ElectronicTicketOrder electronicTicketOrder
	){
		return new TB_ElectronicTicket(new TB_ElectronicTicket.MustProperties() {
			/** 卡号 */
			@Override public String getNumber(){
				return Generator.generate(0, 32);
			}
			/** 状态 */
			@Override public bairui.international.model.status.State_ElectronicTicket getState(){
				return bairui.international.model.status.State_ElectronicTicket.Canceled;
			}
			/** 电子券单 */
			@Override public bairui.international.model.domain.jpa.TB_ElectronicTicketOrder getElectronicTicketOrder(){
				return electronicTicketOrder;
			}
			/** 转送次数 */
			@Override public Integer getTransmitCount(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.intRandom(1, Integer.MAX_VALUE);
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_ElectronicTicket saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ElectronicTicketOrder electronicTicketOrder
	,bairui.international.model.domain.jpa.TB_User assignedUser
	,bairui.international.model.domain.jpa.TB_User takor
	,bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_ElectronicTicket");
		return (TB_ElectronicTicket)repository.save(newAll(
				electronicTicketOrder
				,assignedUser
				,takor
				,productOrder
			));
	}
	
	public static TB_ElectronicTicket newAll(
		bairui.international.model.domain.jpa.TB_ElectronicTicketOrder electronicTicketOrder
	,bairui.international.model.domain.jpa.TB_User assignedUser
	,bairui.international.model.domain.jpa.TB_User takor
	,bairui.international.model.domain.jpa.TB_ProductOrder productOrder
	){
		return new TB_ElectronicTicket(
			new TB_ElectronicTicket.MustProperties() {
				/** 卡号 */
				@Override public String getNumber(){
					return Generator.generate(0, 32);
				}
				/** 状态 */
				@Override public bairui.international.model.status.State_ElectronicTicket getState(){
					return bairui.international.model.status.State_ElectronicTicket.Canceled;
				}
				/** 电子券单 */
				@Override public bairui.international.model.domain.jpa.TB_ElectronicTicketOrder getElectronicTicketOrder(){
					return electronicTicketOrder;
				}
				/** 转送次数 */
				@Override public Integer getTransmitCount(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.intRandom(1, Integer.MAX_VALUE);
				}
			},
			new TB_ElectronicTicket.OptionalSingleProperties() {
				/** 接受分配用户 */
				@Override public bairui.international.model.domain.jpa.TB_User getAssignedUser(){
					return assignedUser;
				}
				/** 领取者 */
				@Override public bairui.international.model.domain.jpa.TB_User getTakor(){
					return takor;
				}
				/** 分配时间 */
				@Override public java.util.Date getAssignDate(){
					return new java.util.Date();
				}
				/** 领取时间 */
				@Override public java.util.Date getTakeDate(){
					return new java.util.Date();
				}
				/** 使用时间 */
				@Override public java.util.Date getUseDate(){
					return new java.util.Date();
				}
				/** 产品订单 */
				@Override public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(){
					return productOrder;
				}
				/** 二维码 */
				@Override public String getDimensionalUrl(){
					return Generator.generate(0, 255);
				}
			}
		);
	}
	

}
